package demo1;

public class Test {
    public static void main(String[] args) {
        int[] array={1,2,3};
        int index=10;
        System.out.println(getElement(array, index));
    }
    public static int getElement(int[] array,int index){
        if(array==null){
            throw new NullPointerException("空指针异常");
        }else if(index<0||index>=array.length){
            throw new ArrayIndexOutOfBoundsException("数组越界异常");
        }
        return array[index];
    }
}
